package com.decent.web.system.service.impl;

import com.decent.common.bo.MessageBean;
import com.decent.common.enums.ErrorCodeEnum;
import com.decent.web.system.dao.SystemBannerDao;
import com.decent.web.system.service.SystemBannerService;
import com.decent.web.system.vo.SystemBannerVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * banner操作--service层
 * @author: decent Gjh
 * @date: 2022/10/24/15:43
 * @description:
 */
@Slf4j
@Service
public class SystemBannerServiceImpl implements SystemBannerService {
    private final SystemBannerDao bannerDao;

    public SystemBannerServiceImpl(SystemBannerDao bannerDao) {
        this.bannerDao = bannerDao;
    }

    /**
     * 获取banner
     * @return 含有banner列表的MessageBean
     */
    @Override
    public MessageBean getBanner() {
        List<SystemBannerVO> banners = bannerDao.getBannerList();
        return (banners == null || banners.isEmpty()) ? new MessageBean(ErrorCodeEnum.DATA_NOT_FOUND,"暂无banner"):
                new MessageBean(ErrorCodeEnum.DATA_NOT_FOUND,banners,"获取banner成功");
    }

}
